<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>评论-闲言轻博客</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
{{template "comm/link.html"}}
</head>
<body class="lay-blog">
{{template "comm/header.html".}}
<div class="container-wrap">
    <div class="container container-message container-details">
        <div class="contar-wrap">
            <div class="item">
                <div class="item-box  layer-photos-demo1 layer-photos-demo">
                    <h3><a href="#">{{.note.Title}}</a></h3>
                    <h5>发布于：<span>{{date .note.UpdatedAt "Y-m-d H:i:s"}}</span></h5>
                    <div class="body" style="overflow-y: auto">
                    {{str2html .note.Content}}
                    </div>
                {{/*<img src="../res/static/images/item.png" alt="">*/}}
                    <div class="count layui-clear">
                        <span class="pull-left">阅读 <em>{{.note.Visit}}</em></span>
                        <span class="pull-right like {{if .praise}}layblog-this{{end}}" data-type="note"
                              data-key="{{.note.Key}}">
                            <i class="layui-icon layui-icon-praise"></i>
                            <em class="value">{{.note.Praise}}</em>
                        </span>
                    </div>
                </div>
            </div>
        {{if .note.Files}}
            <div class="item">
                <div class="item-box  layer-photos-demo1 layer-photos-demo">
                    <h3>附件下载</h3>
                    <div id="files" style="display: none">{{.note.Files}}</div>
                    <div class="layui-upload-list">
                        <table class="layui-table " lay-skin="line">
                            <thead>
                            <tr>
                                <th>文件名</th>
                            </tr>
                            </thead>
                            <tbody id="demoList"></tbody>
                        </table>
                    </div>
                </div>
            </div>
        {{end}}

            <a name="comment"> </a>
            <div class="comt layui-clear">
                <a href="javascript:;" class="pull-left">评论</a>
                <a href="/comment/{{.note.Key}}" class="pull-right">写评论</a>
            </div>
            <div id="LAY-msg-box">
            {{range .messages}}
                {{template "comm/tpl_msg.html" .}}
                {{end}}
            </div>
        </div>
    </div>
</div>
{{template "comm/footer.html"}}
<script>
    layui.use(['form', 'jquery', 'layer', 'sysn', 'util'], function () {
        var form = layui.form,
                sysn = layui.sysn,
                $ = layui.jquery,
                layer = layui.layer,
                util = layui.util;
        //执行
        var option = {};
    {{if and .IsLogin (eq2 .User.ID .note.UserID) }}
        option = {
            bar1: '&#xe642;',
            bar2: '&#xe640;',
            click: function (type) {
                if (type === 'bar1') {
                    window.location.href = "/note/edit/{{.note.Key}}";
                } else if (type === 'bar2') {
                    layer.confirm('您确定要删除当前文章？', {
                        btn: ['确定', '取消'] //按钮
                    }, function () {
                        sysn.post("/note/del/{{.note.Key}}")
                                .success(function (data) {
                                    layer.msg(data.msg);
                                    if (data.action) {
                                        setTimeout(function () {
                                            window.location.href = data.action;
                                        }, 300)
                                    }
                                }).run();
                    }, function () {
                    });

                }
            }

        };
    {{else if not .IsLogin}}
        option = {
            bar1: '&#xe770;',
            click: function (type) {
                if (type === 'bar1') {
                    window.location.href = "/user";
                }
            }
        };
    {{end}}
        util.fixbar(option);
        var fielstemp = $("#files").text(), filelists = $("#demoList");
        if (fielstemp) {
            var otherfiles = fielstemp.split(";");
            for (var i = 0; i < otherfiles.length; i++) {
                var index = i;
                sysn.get(otherfiles[index] + ".json")
                        .async(false)
                        .success(function (file) {
                            var tr = $(['<tr id="upload-' + index + '">'
                                , '<td><a  href="' + otherfiles[index] + '" target="_blank">' + file.Filename + '</a></td>'
                                , '</tr>'].join(''));
                            tr.addClass("done").data("link", otherfiles[index]);
                            filelists.append(tr);
                        }).run({novaild: true});
            }
        }
    });

</script>
</body>
</html>